home *** CD-ROM | disk | FTP | other *** search
/ D.I.S.C. 1 / D.I.S.C. 1.adf / sources / stars.s
Text File  |  2022-11-05  |  3KB  |  159 lines

  1. *************************
  2. ** 3D Stars in Sprites **
  3. ** ©'89 MMS of Level 4 **
  4. *************************
  5.  
  6.     jmp    $30000
  7.     org    $30000        ; Startadresse $30000
  8.     load    $30000
  9.  
  10. Field=    $40000            ; Zwischenspeicher
  11. Spr1=    Field+244        ; Sprite 1
  12. Spr2=    Spr1+1608        ; Sprite 2
  13. Stars=    Spr2+1608        ; Koordinaten
  14.  
  15. Anz=40
  16.  
  17. o:    move.l    #Start,$80.w
  18.     trap    #0        ; Prg runs in TRAP#0
  19.     rts
  20.  
  21. Start:    move.w    #$2700,sr    ; IRQ out / Supervisor
  22.     move.w    #$8400,$96(a5)
  23.     clr.l    0        ; Other sprites off !
  24.     lea.l    $dff000,a5
  25.     bsr.L    Init_Stars    ; Initizate Routine
  26.     move.l    #Copper,$80(a5)
  27.  
  28. Sync:    cmp.b    #$f1,$6(a5)    ; Auf Rasterzeile $f1 warten
  29.     bne.s    sync
  30.  
  31.     move.w    #$0fff,$180(a5)    ; Col00 = weiss
  32.  
  33.     bsr.L    Write_Stars    ; Calculate Pos. + Write in Sprites
  34.     bsr.L    Move_Stars    ; Move Stars
  35.  
  36.     move.w    #$0000,$180(a5)    ; Col00 = schwarz
  37.  
  38.     and.b    #$40,$bfe001    ; Mouse button ?
  39.     bne.s    Sync
  40.  
  41.     lea.l    GfxName,a1    ; Open GFX library
  42.     move.l    4.w,a6
  43.     jsr    -408(a6)
  44.     move.l    d0,a1
  45.     move.l    $26(a1),$80(a5)    ; old Copper
  46.     jsr    -414(a6)    ; Close GFX library
  47.     rte
  48.  
  49. GfxName:dc.b    "graphics.library",0
  50. even
  51. Copper:    dc.w    $0180,$0000,$0182,$0000
  52.     dc.w    $008e,$2900,$0090,$f1ff,$0092,$0038,$0094,$00d0
  53.     dc.w    $0100,$1200,$00e0,$0000,$00e2,$0000
  54.     
  55.     dc.w    $0120,spr1/$10000,$0122,spr1        ; Sprite0
  56.     dc.w    $0124,spr2/$10000,$0126,spr2        ; Sprite1
  57.     dc.w    $01a2,$0fff,$01a4,$0888,$01a6,$0333    ; SprCol0+1
  58.  
  59.     dc.w    $0128,$0000,$012a,$0000,$012c,$0000,$012e,$0000
  60.     dc.w    $0130,$0000,$0132,$0000,$0134,$0000,$0136,$0000
  61.     dc.w    $0138,$0000,$013a,$0000,$013c,$0000,$013e,$0000
  62.     dc.w    $ffff,$fffe
  63.  
  64. Rnd:    move.w    $6(a5),d0
  65.     muls    Zufall,d0
  66.     move.w    d0,Zufall
  67.     add.w    #$4123,Zufall
  68.     rts
  69.  
  70. Zufall:    dc.w    $1234,$0
  71.  
  72. Init_Stars:
  73.     lea.l    Stars,a0
  74.     move.w    #Anz,d7
  75. StarField:
  76.     moveq    #0,d0
  77.     bsr.s    Rnd
  78.     move.b    d0,(a0)+    ;Set x
  79.     bsr.s    Rnd
  80.     move.b    d0,(a0)+    ;Set y
  81. Try_z:    bsr.s    Rnd
  82.     cmp.b    #4,d0
  83.     bmi.s    Try_z
  84.     move.b    d0,(a0)+    ;Set z
  85.     dbf    d7,StarField
  86.     rts
  87.  
  88. Write_Stars:
  89.     move.w    #$0100,$40(a5)    ; Clear Field
  90.     move.l    #Field+$28,$54(a5)
  91.     move.w    #0,$66(a5)
  92.     move.w    #[101*64]+1,$58(a5)
  93.  
  94.     lea.l    Field,a0
  95.     lea.l    Stars,a2
  96.     move.w    #Anz,d7
  97. Writie:    move.b    (a2)+,d0    ;x->d0
  98.     move.b    (a2)+,d1    ;y->d1
  99.     move.b    (a2)+,d2    ;z->d2
  100.     lsr.w    #2,d2
  101.     ext.w    d0
  102.     ext.w    d1
  103.     ext.l    d0
  104.     ext.l    d1
  105.  
  106.     divs    d2,d0        ;x/z
  107.     divs    d2,d1        ;y/z
  108.  
  109.     add.b    #144,d0        ; x mitte
  110.     add.b    #141,d1        ; y mitte
  111.     and.w    #$ff,d1
  112.     move.b    d0,(a0,d1.w)    ; Write in Field
  113.     dbf    d7,Writie
  114.  
  115.     lea.l    Spr1,a0        ; Write in Sprite0+1
  116.     lea.l    Spr2,a1
  117.     lea.l    Field,a2
  118.     move.w    #$29,d1
  119.     move.w    #99,d7        ; 200 Zeilen !
  120. Writy:    move.b    (a2,d1.w),d0
  121.     beq.s    NextSpr
  122.     move.b    d1,(a0)+
  123.     move.b    d0,(a0)+
  124.     addq.b    #1,d1
  125.     move.b    d1,(a0)+
  126.     move.b    #0,(a0)+
  127.     move.l    #$a800d800,(a0)+; Shit pattern (proves Sprites!)
  128.     subq.b    #1,d1
  129. NextSpr:addq.b    #1,d1
  130.     move.b    (a2,d1.w),d0
  131.     beq.s    EndSpr
  132.     move.b    d1,(a1)+
  133.     move.b    d0,(a1)+
  134.     addq.b    #1,d1
  135.     move.b    d1,(a1)+
  136.     move.b    #0,(a1)+
  137.     move.l    #$a800d800,(a1)+
  138.     subq.b    #1,d1
  139. EndSpr:    addq.b    #1,d1
  140.     dbf    d7,Writy
  141.     move.l    #0,(a0)        ; Sprites over
  142.     move.l    #0,(a1)
  143.     rts
  144.  
  145. Move_Stars:
  146.     lea.l    Stars,a0
  147.     move.w    #Anz,d7
  148. Movete:    sub.b    #1,2(a0)    ; Move'em
  149.     cmp.b    #4,2(a0)
  150.     bge.s    NochNix
  151.     move.b    #$80,2(a0)    ; z=128
  152.     bsr.L    Rnd
  153.     move.b    d0,(a0)        ; x=rnd
  154.     bsr.L    Rnd
  155.     move.b    d0,1(a0)    ; y=rnd
  156. NochNix:lea    3(a0),a0
  157.     dbf    d7,Movete
  158.     rts
  159.